home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / GNUChess4_0_58.lha / gnuchess-4.0 / src / new / nondsp.c < prev    next >
C/C++ Source or Header  |  1992-08-26  |  16KB  |  736 lines

  1. /*
  2.  * nondsp.c - UNIX & MSDOS NON-DISPLAY, AND CHESSTOOL interface for Chess
  3.  *
  4.  * Copyright (c) 1988,1989,1990 John Stanback
  5.  * Copyright (c) 1992 Free Software Foundation
  6.  *
  7.  * This file is part of GNU CHESS.
  8.  *
  9.  * GNU Chess is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2, or (at your option)
  12.  * any later version.
  13.  *
  14.  * GNU Chess is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with GNU Chess; see the file COPYING.  If not, write to
  21.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23.  
  24. #include <ctype.h>
  25. #include <signal.h>
  26. #ifdef MSDOS
  27. #include <dos.h>
  28. #include <conio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <time.h>
  32. #else
  33. #include <sys/param.h>
  34. #include <sys/types.h>
  35. #include <sys/file.h>
  36. #include <sys/ioctl.h>
  37. void TerminateSearch (int), Die (int);
  38.  
  39. #endif /* MSDOS */
  40.  
  41. #include "gnuchess.h"
  42.  
  43. #ifdef DEBUG
  44. short int debuglevel = 0;
  45.  
  46. #endif /* DEBUG */
  47. unsigned short int MV[MAXDEPTH];
  48. int MSCORE;
  49.  
  50. #if defined CHESSTOOL || defined XBOARD
  51. short int chesstool = 1;
  52.  
  53. #else
  54. short int chesstool = 0;
  55.  
  56. #endif /* CHESSTOOL */
  57. extern char mvstr[4][6];
  58. int mycnt1, mycnt2;
  59. char *DRAW;
  60. extern char *InPtr;
  61. extern short int pscore[];
  62.  
  63. void
  64. Initialize (void)
  65. {
  66.   mycnt1 = mycnt2 = 0;
  67. #if defined CHESSTOOL || defined XBOARD
  68. #ifndef SYSV
  69.   setlinebuf (stdout);
  70. #else
  71.   setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
  72. #endif
  73.   printf (CP[43]);        /*Chess*/
  74.   if (!TCflag && (MaxResponseTime == 0))
  75.     MaxResponseTime = 15L*100L;
  76. #endif /* CHESSTOOL */
  77. }
  78.  
  79. void
  80. ExitChess (void)
  81. {
  82.   signal (SIGTERM, SIG_IGN);
  83.   ListGame ();
  84.   exit (0);
  85. }
  86.  
  87. #ifndef MSDOS            /* never called!!! */
  88. void
  89. Die (int sig)
  90. {
  91.   char s[80];
  92.  
  93.   ShowMessage (CP[31]);        /*Abort?*/
  94.   scanz ("%s", s);
  95.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  96.     ExitChess ();
  97. }
  98.  
  99. #endif /* MSDOS */
  100.  
  101. void
  102. TerminateSearch (int sig)
  103. {
  104. #ifdef MSDOS
  105.   sig++;            /* shut up the compiler */
  106. #endif /* MSDOS */
  107.   if (!flag.timeout)
  108.     flag.musttimeout = true;
  109.   flag.bothsides = false;
  110. }
  111.  
  112.  
  113. void
  114. help (void)
  115. {
  116.   ClrScreen ();
  117.   /*printz ("CHESS command summary\n");*/
  118.   printz (CP[40]);
  119.   printz ("----------------------------------------------------------------\n");
  120.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  121.   printz (CP[158]);
  122.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  123.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  124.   /*printz ("a7a8q     promote pawn to queen\n");*/
  125.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  126.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  127.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  128.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  129.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  130.   /*printz ("bd        redraw board            reverse   board display\n");*/
  131.   printz (CP[130]);
  132.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount, BOOKSIZE);*/
  133.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  134.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  135.   printz (CP[200]);
  136.   /*printz ("edit      edit board              force     enter game moves\n");*/
  137.   printz (CP[153]);
  138.   /*printz ("switch    sides with computer     both      computer match\n");*/
  139.   printz (CP[194]);
  140.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  141.   printz (CP[202]);
  142.   /*printz ("depth     set search depth        clock     set time control\n");*/
  143.   printz (CP[149]);
  144.   /*printz ("post      principle variation     hint      suggest a move\n");*/
  145.   printz (CP[177]);
  146.   /*printz ("save      game to file            get       game from file\n");*/
  147.   printz (CP[188]);
  148.   /*printz ("random    randomize play          new       start new game\n");*/
  149.   printz (CP[181]);
  150.   printz ("----------------------------------------------------------------\n");
  151.   /*printz ("Computer: %-12s Opponent:            %s\n",*/
  152.   printz (CP[46],
  153.       ColorStr[computer], ColorStr[opponent]);
  154.   /*printz ("Depth:    %-12d Response time:       %d sec\n",*/
  155.   printz (CP[51],
  156.       MaxSearchDepth, MaxResponseTime/100);
  157.   /*printz ("Random:   %-12s Easy mode:           %s\n",*/
  158.   printz (CP[99],
  159.       (dither) ? CP[93] : CP[92], (flag.easy) ? CP[93] : CP[92]);
  160.   /*printz ("Beep:     %-12s Transposition file: %s\n",*/
  161.   printz (CP[36],
  162.       (flag.beep) ? CP[93] : CP[92], (flag.hash) ? CP[93] : CP[92]);
  163.   /*printz ("Time Control %s %d moves %d seconds %d opr %d depth\n", (TCflag) ? "ON" : "OFF",*/
  164.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  165.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  166.   signal (SIGINT, TerminateSearch);
  167. #ifndef MSDOS
  168.   signal (SIGQUIT, TerminateSearch);
  169. #endif /* MSDOS */
  170. }
  171.  
  172. void
  173. EditBoard (void)
  174.  
  175. /*
  176.  * Set up a board position. Pieces are entered by typing the piece followed
  177.  * by the location. For example, Nf3 will place a knight on square f3.
  178.  */
  179.  
  180. {
  181.   short a, r, c, sq, i, found;
  182.   char s[80];
  183.  
  184.   flag.regularstart = false;
  185.   Book = 0;
  186.   ClrScreen ();
  187.   UpdateDisplay (0, 0, 1, 0);
  188.   /*printz (".   exit to main\n");*/
  189.   printz (CP[29]);
  190.   /*printz ("#   clear board\n");*/
  191.   printz (CP[28]);
  192.   /*printz ("c   change sides\n");*/
  193.   printz (CP[136]);
  194.   /*printz ("enter piece & location: \n");*/
  195.   printz (CP[155]);
  196.  
  197.   a = white;
  198.   do
  199.     {
  200.       scanz ("%s", s);
  201.       found=0;
  202.       if (s[0] == CP[28][0])    /*#*/
  203.     for (sq = 0; sq < 64; sq++)
  204.       {
  205.         board[sq] = no_piece;
  206.         color[sq] = neutral;
  207.       }
  208.       if (s[0] == CP[136][0])    /*c*/
  209.     a = otherside[a];
  210.       c = s[1] - 'a';
  211.       r = s[2] - '1';
  212.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  213.     {
  214.       sq = locn (r, c);
  215.       color[sq] = a;
  216.       board[sq] = no_piece;
  217.       for (i = no_piece; i <= king; i++)
  218.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  219.           {
  220.         board[sq] = i;
  221.         found=1;
  222.         break;
  223.           }
  224.       if (found==0) color[sq] = neutral;    
  225.     }
  226.   } while (s[0] != CP[29][0]);
  227.   for (sq = 0; sq < 64; sq++)
  228.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  229.   GameCnt = 0;
  230.   Game50 = 1;
  231.   ZeroRPT ();
  232.   Sdepth = 0;
  233.   InitializeStats ();
  234.   ClrScreen ();
  235.   UpdateDisplay (0, 0, 1, 0);
  236. }
  237.  
  238. void
  239. SetupBoard (void)
  240.  
  241. /*
  242.  * Compatibility with Unix chess and the nchesstool. Set up a board position.
  243.  * Eight lines of eight characters are used to setup the board. a8-h8 is the
  244.  * first line. Black pieces are  represented  by  uppercase characters.
  245.  */
  246.  
  247. {
  248.   short r, c, sq, i;
  249.   char ch;
  250.   char s[80];
  251.  
  252.   NewGame ();
  253.  
  254.   gets (s);            /* skip "setup" command */
  255.   for (r = 7; r >= 0; r--)
  256.     {
  257.       gets (s);
  258.       for (c = 0; c <= 7; c++)
  259.     {
  260.       ch = s[c];
  261.       sq = locn (r, c);
  262.       color[sq] = neutral;
  263.       board[sq] = no_piece;
  264.       for (i = no_piece; i <= king; i++)
  265.         if (ch == pxx[i])
  266.           {
  267.         color[sq] = black;
  268.         board[sq] = i;
  269.         break;
  270.           }
  271.         else if (ch == qxx[i])
  272.           {
  273.         color[sq] = white;
  274.         board[sq] = i;
  275.         break;
  276.           }
  277.     }
  278.     }
  279.   for (sq = 0; sq < 64; sq++)
  280.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  281.   InitializeStats ();
  282.   ClrScreen ();
  283.   UpdateDisplay (0, 0, 1, 0);
  284.   /*printz ("Setup successful\n");*/
  285.   printz (CP[106]);
  286. }
  287.  
  288. void
  289. ShowDepth (char ch)
  290. {
  291. #ifdef MSDOS
  292.   ch++;                /* shut up the compiler */
  293. #endif /* MSDOS */
  294. }
  295.  
  296.  
  297. void
  298. ShowLine (short unsigned int *bstline)
  299. {
  300.   register int i;
  301.  
  302.   for (i = 1; bstline[i] > 0; i++)
  303.     {
  304.       if ((i > 1) && (i % 8 == 1))
  305.     printf ("\n                          ");
  306.       algbr ((short) (bstline[i] >> 8), (short) (bstline[i] & 0xFF), false);
  307.       printf ("%5s ", mvstr[0]);
  308.     }
  309.   printf ("\n");
  310. }
  311.  
  312. void
  313. ShowResults (short int score, short unsigned int *bstline, char ch)
  314. {
  315. #if !defined CHESSTOOL
  316.   if (flag.post)
  317.     {
  318.       ElapsedTime (2);
  319.       printf ("%2d%c %6d %4ld %8ld  ", Sdepth, ch, score, et / 100, NodeCnt);
  320.       ShowLine (bstline);
  321.     }
  322. #else
  323.   register int i;
  324.  
  325.   MSCORE = score;
  326.   MV[30] = ch;
  327.   for (i = 1; bstline[i] > 0; i++)
  328.     {
  329.       MV[i] = bstline[i];
  330.     } MV[i] = 0;
  331. #endif /* CHESSTOOL */
  332. }
  333.  
  334. void
  335. SearchStartStuff (short int side)
  336. {
  337.   signal (SIGINT, TerminateSearch);
  338. #ifndef MSDOS
  339.   signal (SIGQUIT, TerminateSearch);
  340. #endif /* MSDOS */
  341. #if !defined CHESSTOOL
  342.   if (flag.post)
  343.     {
  344.       printf (CP[123],
  345.            TCmoves - TimeControl.moves[side] + 1,
  346.            ResponseTime, TimeControl.clock[side]);
  347.     }
  348. #endif /* CHESSTOOL */
  349. }
  350. void
  351. OutputMove (void)
  352. {
  353. #ifdef DEBUG11
  354.   if (1)
  355.     {
  356.       FILE *D;
  357.       extern unsigned short int PrVar[];
  358.       char d[80];
  359.       int r, c, l, i;
  360.       D = fopen ("/tmp/DEBUGA", "a+");
  361.       fprintf (D, "inout move is %s\n", mvstr[0]);
  362.       strcpy (d, mvstr[0]);
  363.       for (i = 1; PrVar[i] > 0; i++)
  364.     {
  365.       algbr ((short) (PrVar[i] >> 8), (short) (PrVar[i] & 0xFF), false);
  366.       fprintf (D, "%5s ", mvstr[0]);
  367.     }
  368.       fprintf (D, "\n");
  369.  
  370.       fprintf (D, "\n current board is\n");
  371.       for (r = 7; r >= 0; r--)
  372.     {
  373.       for (c = 0; c <= 7; c++)
  374.         {
  375.           l = locn (r, c);
  376.           if (color[l] == neutral)
  377.         fprintf (D, " -");
  378.           else if (color[l] == white)
  379.         fprintf (D, " %c", qxx[board[l]]);
  380.           else
  381.         fprintf (D, " %c", pxx[board[l]]);
  382.         }
  383.       fprintf (D, "\n");
  384.     }
  385.       fprintf (D, "\n");
  386.       fclose (D);
  387.       strcpy (mvstr[0], d);
  388.     }
  389. #endif
  390. if(flag.illegal){printf("%s\n",CP[225]);return;}
  391. if (mvstr[0][0] == '\0') goto nomove;
  392. #if defined CHESSTOOL
  393.   if (computer == black)
  394.     printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  395.   else
  396.     printz ("%d. %s\n", ++mycnt1, mvstr[0]);
  397. #else
  398. #ifdef XBOARD
  399.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  400. #else
  401.   printz ("%d. ... %s\n", ++mycnt1, mvstr[0]);
  402. #endif
  403. #endif /* CHESSTOOL */
  404. #ifdef notdef
  405.   if (flag.post)
  406.     {
  407.       register int i;
  408.  
  409.       printz (" %6d%c ", MSCORE, MV[30]);
  410.       for (i = 1; MV[i] > 0; i++)
  411.     {
  412.       algbr ((short) (MV[i] >> 8), (short) (MV[i] & 0xFF), false);
  413.       printz ("%5s ", mvstr[0]);
  414.     }
  415.     }
  416.   printz ("\n");
  417. #endif
  418. nomove:
  419.   if ((rootnode.flags & draw)||(rootnode.score == -9999)||
  420.       (rootnode.score == 9998)) goto summary;
  421. #if !defined CHESSTOOL
  422.   if (flag.post)
  423.     {
  424.       short h, l, t;
  425.  
  426.       h = TREE;
  427.       l = 0;
  428.       t = TREE >> 1;
  429.       while (l != t)
  430.     {
  431.       if (Tree[t].f || Tree[t].t)
  432.         l = t;
  433.       else
  434.         h = t;
  435.       t = (l + h) >> 1;
  436.     }
  437.       /*printf ("Nodes %ld Tree %d Eval %ld Rate %ld RS high %ld low %ld\n",*/
  438.       printf (CP[89],
  439.            NodeCnt, t, EvalNodes, (et) ? (NodeCnt / (et / 100)) : 0, reminus, replus);
  440.       /*printf ("Hin/Hout/Coll/Fin/Fout = %ld/%ld/%ld/%ld/%ld\n",*/
  441.       printf (CP[71],
  442.            HashAdd, HashCnt, THashCol, HashCol, FHashAdd, FHashCnt);
  443.     }
  444.   UpdateDisplay (rootnode.f, rootnode.t, 0, rootnode.flags);
  445.   /*printf ("My move is: %s\n", mvstr[0]);*/
  446.   printf (CP[83], mvstr[0]);
  447.   if (flag.beep)
  448.     printz ("%c", 7);
  449. #endif /* CHESSTOOL */
  450.  summary:
  451.   if (rootnode.flags & draw)
  452.     /*    printf ("Drawn game!\n");*/
  453.     printf (CP[57]);
  454.   else if (rootnode.score == -9999)
  455.     printf("%s mates!\n",ColorStr[opponent]);
  456.   else if (rootnode.score == 9998)
  457.     printf("%s mates!\n",ColorStr[computer]);
  458. #if !defined CHESSTOOL && !defined XBOARD
  459. #ifdef VERYBUGGY
  460.   else if (rootnode.score < -9000)
  461.     printf("%s has a forced mate!\n",ColorStr[opponent]);
  462.   else if (rootnode.score > 9000)
  463.     printf("%s has a forced mate!\n",ColorStr[computer]);
  464. #endif /*VERYBUGGY*/
  465. #endif /* CHESSTOOL */
  466. }
  467.  
  468. void
  469. ClrScreen (void)
  470. {
  471. #if !defined CHESSTOOL && !defined XBOARD
  472.   printz ("\n");
  473. #endif
  474. }
  475.  
  476. void
  477. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  478. {
  479.  
  480.   short r, c, l, m;
  481.  
  482.   if (redraw && !chesstool)
  483.     {
  484.       printz ("\n");
  485.       r = TimeControl.clock[white] / 6000;
  486.       c = (TimeControl.clock[white] % 6000) / 100;
  487.       l = TimeControl.clock[black] / 6000;
  488.       m = (TimeControl.clock[black] % 6000) / 100;
  489.       /*printz ("White %d:%02d  Black %d:%02d\n", r, c, l, m);*/
  490.       printz (CP[116], r, c, l, m);
  491.       printz ("\n");
  492.       for (r = 7; r >= 0; r--)
  493.     {
  494.       for (c = 0; c <= 7; c++)
  495.         {
  496.           l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  497.           if (color[l] == neutral)
  498.         printz (" -");
  499.           else if (color[l] == white)
  500.         printz (" %c", qxx[board[l]]);
  501.           else
  502.         printz (" %c", pxx[board[l]]);
  503.         }
  504.       printz ("\n");
  505.     }
  506.       printz ("\n");
  507.     }
  508. }
  509.  
  510. void
  511. skip ()
  512. {
  513.   while (*InPtr != ' ')
  514.     InPtr++;
  515.   while (*InPtr == ' ')
  516.     InPtr++;
  517. }
  518. void
  519. skipb ()
  520. {
  521.   while (*InPtr == ' ')
  522.     InPtr++;
  523. }
  524.  
  525. void
  526. ShowMessage (char *s)
  527. {
  528.   printf("%s\n", s);
  529. }
  530.  
  531. void
  532. ShowSidetoMove (void)
  533. {
  534. }
  535.  
  536. void
  537. PromptForMove (void)
  538. {
  539. #if !defined CHESSTOOL && !defined XBOARD
  540.   /*printz ("\nYour move is? ");*/
  541.   printz (CP[124]);
  542. #endif /* CHESSTOOL */
  543. }
  544.  
  545.  
  546. void
  547. ShowCurrentMove (short int pnt, short int f, short int t)
  548. {
  549. #ifdef MSDOS
  550.   f++;
  551.   t++;
  552.   pnt++;            /* shut up the compiler */
  553. #endif /* MSDOS */
  554. }
  555.  
  556. void
  557. ChangeAlphaWindow (void)
  558. {
  559.   printz ("WAwindow: ");
  560.   scanz ("%hd", &WAwindow);
  561.   printz ("BAwindow: ");
  562.   scanz ("%hd", &BAwindow);
  563. }
  564.  
  565. void
  566. ChangeBetaWindow (void)
  567. {
  568.   printz ("WBwindow: ");
  569.   scanz ("%hd", &WBwindow);
  570.   printz ("BBwindow: ");
  571.   scanz ("%hd", &BBwindow);
  572. }
  573.  
  574. void
  575. GiveHint (void)
  576. {
  577.   if (hint)
  578.     {
  579.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  580.       printf(CP[72], mvstr[0]);    /*hint*/
  581.     }
  582.   else
  583.     printz (CP[223]);
  584. }
  585.  
  586. void
  587. SelectLevel (void)
  588. {
  589.   char T[64], *p, *q;
  590.   printz (CP[61]);
  591.   scanz ("%hd %s", &TCmoves, T);
  592.   for (p = T; *p == ' '; p++) ;
  593.   TCminutes = strtol (p, &q, 10);
  594.   if (*q == ':')
  595.     TCseconds = strtol (q + 1, (char **) NULL, 10);
  596.   else
  597.     TCseconds = 0;
  598. #ifdef OPERATORTIME
  599.   printz (CP[94]);
  600.   scanz ("%hd", &OperatorTime);
  601. #endif
  602.   if (TCmoves == 0) {
  603.     TCflag = false;
  604.     MaxResponseTime = TCminutes*60L*100L + TCseconds*100L;
  605.     TCminutes = TCseconds = 0;
  606.   } else {
  607.     TCflag = true;
  608.     MaxResponseTime = 0;
  609.   }
  610.   SetTimeControl ();
  611. }
  612.  
  613. #ifdef DEBUG
  614. void
  615. ChangeDbLev (void)
  616. {
  617.   printz (CP[146]);
  618.   scanz ("%hd", &debuglevel);
  619. }
  620.  
  621. #endif /* DEBUG */
  622.  
  623. void
  624. ChangeSearchDepth (void)
  625. {
  626.   printz ("depth= ");
  627.   scanz ("%hd", &MaxSearchDepth);
  628.   TCflag = !(MaxSearchDepth > 0);
  629. }
  630.  
  631. ChangeHashDepth (void)
  632. {
  633.   printz ("hashdepth= ");
  634.   scanz ("%hd", &HashDepth);
  635.   printz ("MoveLimit= ");
  636.   scanz ("%hd", &HashMoveLimit);
  637. }
  638.  
  639. void
  640. SetContempt (void)
  641. {
  642.   printz ("contempt= ");
  643.   scanz ("%hd", &contempt);
  644. }
  645.  
  646. void
  647. ChangeXwindow (void)
  648. {
  649.   printz ("xwndw= ");
  650.   scanz ("%hd", &xwndw);
  651. }
  652.  
  653. void
  654. ShowPostnValue (short int sq)
  655.  
  656. /*
  657.  * must have called ExaminePosition() first
  658.  */
  659.  
  660. {
  661.   short score;
  662.   char c;
  663.   score = ScorePosition (color[sq]);
  664.   if (color[sq] != neutral){
  665.     printz ("%3d%c ", svalue[sq],(color[sq] == black)?'b':'w');}
  666.   else
  667.     printz(" *   ");
  668. }
  669.  
  670. void
  671. DoDebug (void)
  672. {
  673.   short c, p, sq, tp, tc, tsq, score,j,k;
  674.   char s[40];
  675.  
  676.   ExaminePosition ();
  677.   ShowMessage (CP[65]);
  678.   scanz ("%s", s);
  679.   c = neutral;
  680.   if (s[0] == CP[9][0] || s[0] == CP[9][1])     /* w W*/ c = white;
  681.   if (s[0] == CP[9][2] || s[0] == CP[9][3])     /*b B*/ c = black;
  682.   for (p = king; p > no_piece; p--)
  683.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  684.   if(p > no_piece)
  685.   for(j=7;j>=0;j--){
  686.   for(k=0;k<8;k++){
  687.       sq=j*8+k;
  688.       tp = board[sq];
  689.       tc = color[sq];
  690.       board[sq] = p;
  691.       color[sq] = c;
  692.       tsq = PieceList[c][1];
  693.       PieceList[c][1] = sq;
  694.       ShowPostnValue (sq);
  695.       PieceList[c][1] = tsq;
  696.       board[sq] = tp;
  697.       color[sq] = tc;
  698.     }
  699.       printz("\n");
  700.     }
  701.   score = ScorePosition (opponent);
  702.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  703. }
  704.  
  705. void
  706. DoTable (short table[64])
  707. {
  708.   short  sq,j,k;
  709.   ExaminePosition ();
  710.   for(j=7;j>=0;j--){
  711.   for(k=0;k<8;k++){
  712.     sq=j*8+k;
  713.     printz ("%3d ", table[sq]);
  714.   }
  715. printz("\n");
  716. }
  717. }
  718.  
  719. void
  720. ShowPostnValues (void)
  721. {
  722.   short sq, score,j,k;
  723.   ExaminePosition ();
  724.   for(j=7;j>=0;j--){
  725.   for(k=0;k<8;k++){
  726.   sq=j*8+k;
  727.     ShowPostnValue (sq);
  728.   }
  729.     printz("\n");
  730.   }
  731.   score = ScorePosition (opponent);
  732.  printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  733.  printz("\nhung white %d hung black %d\n",hung[white],hung[black]);
  734. }
  735.  
  736.